/*
** 3173.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Wed Oct  1 18:27:44 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "3173.h" */
#include <stdio.h>

int main()
{
     char num[20], n;	/* using char, saving spaces */
     char i,j;

     scanf("%d%d", (int*)&n, (int*)num);

     for(i = 1; i < n; i++){
	  printf("%d ", num[i - 1]);
	  num[i] = (num[i - 1] + i) % 9;
	  if (num[i] == 0)
	       num[i] = 9;
     }
     printf("%d\n", num[i - 1]);     

     for(i = 1; i < n; i++){
	  for(j = 0; j < i; j++)
	       printf("  ");
	  for(j = i + 1; j < n; j++){
	       if (num[j - 1] == 9)
		    num[j - 1] = 1;
	       else ++(num[j-1]);
	       printf("%d ", num[j - 1]);
	  }
	  if (num[j - 1] == 9)
	       num[j - 1] = 1;
	  else ++(num[j-1]);
	  printf("%d\n", num[j-1]);
     }

     return 0;
}

